<!-- partial-home.html -->

<div class="">

    <div class="row" style="margin-top: 10px;margin-left: 50px">

        <div class="col-lg-12 col-md-12 col-sm-12" >
            <div class="col-lg-2 col-md-2 col-sm-2" >
                <button type="button" class="btn btn-blue btn-outlined btn-sm" ng-click="showAddOne=true">
                    <span class="glyphicon glyphicon-plus"></span>创建课时
                </button>
            </div>

            <!-- 过滤条件 -->
            <div class="col-lg-10 col-md-10 col-sm-10" >
                <span class="glyphicon glyphicon-filter" style="margin-right: 10px"></span>

                课程
                <select style='min-width: 100px;' ng-model="filter.course_id"
                        ng-options="course.id as course.name for course in courseList"
                        ng-change="pageChangeTo(1)">
                </select>
                <span ng-click="filter.course_id=null;pageChangeTo(1)" ng-if="filter.course_id"
                style="cursor:pointer;margin-right: 20px">X</span>

                开始时间 <input type="date" ng-model="filter.starttime"
                            style="line-height: initial" placeholder="yyyy-MM-dd"
                            ng-change="pageChangeTo(1)" />

                结束时间 <input type="date" ng-model="filter.endtime"
                            style="line-height: initial" placeholder="yyyy-MM-dd"
                        ng-change="pageChangeTo(1)" />

            </div>

        </div>

    </div>


    <!-- 添加区域 -->
    <div class="row"
         style="border: 1px solid #B9D4E4;margin:10px;padding: 10px;max-width: 1000px"
         ng-if="showAddOne">
        <br>
        <div class="col-lg-4 col-md-4 col-sm-4">

            课程
            <select style='min-width: 200px;' ng-model="$parent.addEditData.course_id"
                    ng-options="course.id as course.name for course in courseList">
            </select>
            <br>

            描述
            <textarea style="margin-top: 10px;min-width: 200px"
                         placeholder=""  ng-model="addEditData.desc"> </textarea>

        </div>

        <div class="col-lg-8 col-md-8 col-sm-8">

            开始时间 <input type="datetime-local" ng-model="addEditData.starttime"
                        style="line-height: initial" placeholder="yyyy-MM-ddTHH:mm:ss"  />


            <br><br>

            结束时间 <input type="datetime-local" ng-model="addEditData.endtime"
                        style="line-height: initial" placeholder="yyyy-MM-ddTHH:mm:ss"  />




        </div>

        <div class="col-lg-12 col-md-12 col-sm-12" style="margin-top: 20px">
            <button type="button" class="btn btn-green btn-outlined btn-xs" ng-click="addOne()" >
                确定</button>
            <button type="button" class="btn btn-green btn-outlined btn-xs" ng-click="$parent.showAddOne=false" >
                取消</button>
        </div>
    </div>

    <br><br>

    <div class="row col-lg-12 col-md-12 col-sm-12"  ng-if="theList.length>0">

        <table class="table table-hover table-striped table-bordered table-advanced tablesorter" >
            <thead>
            <tr>

                <th width="10%" style="text-align:center">课程</th>
                <th width="25%" style="text-align:center">开始时间</th>
                <th width="25%" style="text-align:center">结束时间</th>
                <th width="10%" style="text-align:center">创建者</th>
                <th width="15%" style="text-align:center">描述</th>
                <th width="15%" style="text-align:center">操作</th>
            </tr>
            </thead>

            <tbody>

            <tr dir-paginate="one in theList| itemsPerPage: pageSize" total-items="totalNum" current-page="$parent.currentPage">

                <td style="text-align:center">
                    <span ng-if="!one.editing">{{one.course_name}}</span>
                    <select ng-if="one.editing" style='min-width: 180px;' ng-model="$parent.addEditData.course_id"
                            ng-options="course.id as course.name  for course in courseList">
                    </select>
                </td>

                <td style="text-align:center">
                    <span ng-if="!one.editing">{{one.starttime.toLocaleString('zh-CN' ,{ hour12: false })}}</span>
                    <input type="datetime-local"   ng-if="one.editing" ng-model="addEditData.starttime"
                           style="line-height: initial"  placeholder="yyyy-MM-ddTHH:mm:ss" >
                </td>

                <td style="text-align:center">
                    <span ng-if="!one.editing">{{one.endtime.toLocaleString('zh-CN',{ hour12: false })}}</span>
                    <input type="datetime-local"   ng-if="one.editing" ng-model="addEditData.endtime"
                           style="line-height: initial"  placeholder="yyyy-MM-ddTHH:mm:ss" >
                </td>

                <td style="text-align:center">
                    <p>{{one.publisher__last_name}}</p>
                </td>

                <td style="text-align:center">
                    <p ng-if="!one.editing">{{one.desc}}</p>
                    <textarea ng-if="one.editing" ng-model="addEditData.desc" ></textarea>
                </td>



                <td style="text-align:center">
                    <button type="button" class="btn btn-green btn-outlined btn-xs"
                            ng-click="editOneBegin(one)" ng-if="!one.editing">
                        编辑
                    </button>
                    <button type="button" class="btn btn-green btn-outlined btn-xs"
                            ng-click="delOne(one)" ng-if="!one.editing">
                        删除
                    </button>
                    <button type="button" class="btn btn-red btn-outlined btn-xs"
                            ng-click="editOneSubmit(one)" ng-if="one.editing">
                        确定</button>
                    <button type="button" class="btn btn-red btn-outlined btn-xs"
                            ng-click="editOneCancel(one)" ng-if="one.editing">
                        取消</button>


                    <button type="button" class="btn btn-green btn-outlined btn-xs"
                            ng-click="showCheckins(one)" ng-if="!one.editing">
                        签到记录
                    </button>
                </td>

            </tr>
            </tbody>

        </table>


        <div class="col-lg-12 col-md-12 col-sm-12 " style="text-align: center;font-family: 'Microsoft YaHei';font-size: medium;">
            <dir-pagination-controls boundary-links="true" on-page-change="pageChangeTo(newPageNumber)"></dir-pagination-controls>
        </div>

<!--签到情况-->

        <div class="col-lg-4 col-md-4 col-sm-4" >
           {{lessonViewCheckin.course_name}} -- {{lessonViewCheckin.starttime.toLocaleString('zh-CN' ,{ hour12: false })}}
        </div>

        <!-- 过滤条件 -->
        <div class="col-lg-6 col-md-6 col-sm-6" ng-if="checkinList.length>0">
            <span class="glyphicon glyphicon-filter" style="margin-right: 10px"></span>
            培训班
            <select  style='min-width: 120px;' ng-model="filter.training_id"
                    ng-options="training.id as training.name for training in trainingList"
                     ng-change="filter_trainingchanged();">
            </select>

            培训班期
            <select  style='min-width: 150px;' ng-model="filter.traininggrade"
                    ng-options="traininggrade as traininggrade.name for traininggrade in traininggradeList"
                     ng-change="filter_traininggradechanged();">
            </select>
        </div>

        <!-- 显示全部签到信息-->
        <div ng-if="!showCheckinByClass" class="col-lg-12 col-md-12 col-sm-12 " 
            style="text-align: center;font-size: large;margin-top: 1em">
            <span ng-repeat="s in checkinList">{{s.student__realname}}({{s.student__traininggrade_id}})&nbsp;</span>
        </div>

        <!-- 显示某个班级签到信息-->
        <div ng-if="showCheckinByClass" class="col-lg-6 col-md-6 col-sm-6 " 
            style="text-align: center;font-size: small;margin-top: 1em">

            <table class="table table-hover table-striped table-bordered table-advanced tablesorter" >
               
                <tbody>
                <tr ng-repeat="s in classStudentsWithCheckin" >

                    <td style="text-align:center">
                        <span >{{s.realname}}</span>
                    </td>

                    <td style="text-align:center">
                        <span ng-if="s.ci"><i class="fa fa-check" style="font-size: large;color:green"></i></span>
                    </td>
                </tr>
                </tbody>
            </table>



        </div>

    </div>

    <div class="note note-success" ng-if="theList.length==0" >
        <h4 class="box-heading">没有查询到课时信息</h4>
    </div>


</div>
</div>